#ifndef DBUS_SERVER_H
#define DBUS_SERVER_H

#include <sdbus-c++/sdbus-c++.h>
#include <functional>
#include <thread>
#include <mutex>

class dbusServer
{
  public:
    dbusServer();
    virtual ~dbusServer();
    void Boot();
    std::function<long(std::string name)> funcCreateTask;
    std::function<void(long)> funcDeleteTask;
    std::function<std::vector<std::string>()> funcGetTaskNameList;
    std::function<std::vector<long>()> funcGetTaskIDList;
    std::function<std::vector<long>(long)> funcGetRecordIDList;
    std::function<std::tuple<long,long,std::string,bool,bool>(long)> funcGetRecordInf;
    std::function<long(long,long)> funcCreateRecord;
    std::function<void()> funcLoadTaskInf;
    std::function<void(long)> funcFinishRecord;
    std::function<std::string(long id)> funcGetRecordPath;
    std::function<std::string(long stuid)> funcGetStudentInf;
    std::function<bool(long stuid)> funcCheckStudentExists;
    std::function<std::vector<long>()> funcGetRecordFinishHandleList;
    std::function<std::vector<long>(long)> funcGetRecordFinishHandleListWithTask;
    std::function<std::tuple<std::string,std::string>(long)> funcGetTaskInf;
    std::function<bool(long,std::string)> funcOutputData;
    static void ThrowError(const char* value);
  private:
    std::mutex initMut;
    std::unique_ptr<sdbus::IConnection> connection;
    std::thread workThread;
};

#endif
